import *as types from '../actions/types'

const default_state = {
    name: null,
    loading: true,
    cover_url: null,
    error: false,
    chapters: [],
    learning_count: 0,
    discription: ''
}

const chapter = (state=default_state, action) => {
    switch (action.type) {
        case types.FETCHING_CHAPTERS:
            return {
                ...state,
                loading: true,
            }
        case types.FETCH_CHAPTERS_SUCCESS:
            return {
                ...action,
                loading: false
                // cover_url: action.cover_url,
                // name: action.name,
                // chapters: action.chapters,
                // loading: false
            }
        case types.FETCH_CHAPTERS_FAIL:
            return {
                ...state,
                error: true
            }      
        default:
            return state
    }
}

export default chapter